{% load static %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <!--<meta name="viewport"-->
    <!--content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>-->
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css"/>
    <link rel="stylesheet" href="/static/css/bodymain.css">
    <link rel="stylesheet" href="/static/css/home.css">
    {#    <link rel="stylesheet" href="/static/js/jquery-3.3.1.min.js">#}
    <script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>

    <title>百知课程后台管理系统-首页
    </title>

    <style>
        .a {
            width: 20px;
            height: 20px;
            border: 1px solid #e1e2e3;
            cursor: pointer;
            display: inline-block;
            text-align: center;
            line-height: 20px;
        }

        .b {
            border: 0;
            width: 20px;
            height: 20px;
            cursor: pointer;
            display: inline-block;
            text-align: center;
            line-height: 20px;
        }

        a {
            text-decoration: none;
        }

        .pagination {

            padding-right: 50px;
        }

        .hide_scorll {
            max-height: 469px;
            overflow: auto;
        }

        .hide_scorll::-webkit-scrollbar {
            display: none
        }


    </style>

    <script>
        {#$(function () {#}
        {#    $(".dele").each(function (i) {#}
        {#        $(this).click(function () {#}
        {#            if (confirm("请确定要删除吗？")) {#}
        {#                id1 = {{ id }}+''#}
        {#                location.href = "{% url 'manage:delete' %}?level={{ level }}&id={{ id }}&number={{ writ.number }}&dele_id=" + $(".id")[i].innerHTML;#}
        {#                return true#}
        {#            } else {#}
        {#                return false#}
        {#            }#}
        {#        })#}
        {#    })#}


        $(function () {
            $(".dele").each(function (i) {
                $(this).click(function () {
                    if (confirm("请确定要删除吗？")) {
                        id1 = {{ id }}+''
                        location.href = "{% url 'manage:delete' %}?level={{ level }}&id={{ id }}&number={{ writ.number }}&dele_id=" + $(".id")[i].innerHTML;
                        return true
                    } else {
                        return false
                    }
                })
            })
        });

        function check() {
            check_content=$('.form-control').val()
            console.log(check_content)
        }

    </script>

</head>
<body>
<!--导航-->
<nav class="navbar navbar-default nav-self">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">百知课程后台管理系统</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="{% url 'manage:quit_login' %}" role="button">{{ username }} <span class="glyphicon glyphicon-log-in"></span></a>
                </li>
                <li>
                    <a href="{% url 'manage:login_out' %}">退出 <span class="glyphicon glyphicon-log-out"></span></a>
                </li>
            </ul>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="">
                </div>
                <div class="btn-group" role="group" aria-label="...">
                    <div class="btn-group" role="group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false" onclick="check()">
                            <span class="glyphicon glyphicon-search"></span>
                        </button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</nav>
<!--内容面板-->
<div class="container-fluid">
    <div class="row">
        <!-- Nav tabs -->
        <div class="panel-group col-sm-2 left-side-bar" id="accordion" role="tablist" aria-multiselectable="true">
            <div>
                <div class="panel panel-default hide_scorll">
                    <div class="panel-heading left-side-header">
                        <a href="{% url 'manage:base' %}?id=0&&level=0">百知课程
                        </a></div>
                    {% for type3 in type1 %}

                        <div class="course-python">
                            <a href="{% url 'manage:base' %}?id={{ type3.id }}&&level={{ type3.level }}">{{ type3.title }}
                            </a></div>

                        {% for type4 in type2 %}
                            {% if type4.parent_id == type3.id %}
                                <div class="list-group">
                                    <a href="{% url 'manage:base' %}?id={{ type4.id }}&&level={{ type4.level }}"
                                       class="list-group-item">{{ type4.title }}</a>
                                </div>
                            {% endif %}
                        {% endfor %}


                    {% endfor %}
                </div>
            </div>
        </div>
        <!-- Tab panes 详情展示面板 -->
        <div class="tab-content col-sm-10 right-side">

            <div class="panel panel-default right-side-content">
                <ol class="breadcrumb">
                    当前位置：
                    <li><a href="{% url 'manage:base' %}?id=0&&level=0">百知课程</a></li>

                    {% if level == '1' %}
                        <li>
                            {% for type3 in type1 %}
                                {% if type3.id == id %}
                                    {{ type3.title }}
                                {% endif %}
                            {% endfor %}
                        </li>
                    {% endif %}

                    {% if level == '2' %}
                        <li>
                            {% for type4 in type2 %}
                                {% if id == type4.id %}
                                    {# 为了获取2级分类的 type4.parent_id ，进而获得父类型的标题#}
                                    {% for type3 in type1 %}
                                        {% if type3.id == type4.parent_id %}
                                            <a href="{% url 'manage:base' %}?id={{ type3.id }}&&level={{ type3.level }}">{{ type3.title }}</a>
                                        {% endif %}
                                    {% endfor %}
                                {% endif %}
                            {% endfor %}
                        </li>
                        <li>
                            {% for type4 in type2 %}
                                {% if type4.id == id %}
                                    {{ type4.title }}
                                {% endif %}
                            {% endfor %}
                        </li>
                    {% endif %}


                </ol>
                <div class="panel-body caret_parent">

                    <a href=" {% url 'manage:base' %}?ride-time=2&ride_count={{ ride_count }}&level={{ level }}&id={{ id }}&ride_type=1"
                       class="btn btn-default sort1">阅读量
                        <span id="sort1" class="glyphicon glyphicon-arrow-down"></span></a>
                    <a href=" {% url 'manage:base' %}?ride_time={{ ride_time }}&ride_count=2&level={{ level }}&id={{ id }}&ride_type=1"
                       class="btn btn-default sort2">发布时间
                        <span id="sort2" class="glyphicon glyphicon-arrow-down"></span></a>
                    <a href="{% url 'manage:addArticle' %}" class="btn pull-right base-color add-course"><span
                            class="glyphicon glyphicon-plus"></span> 增加文章</a>
                    <a href="{% url 'manage:addCourse' %}" class="btn pull-right base-color"><span
                            class="glyphicon glyphicon-plus"></span> 增加课程/分类</a>
                </div>
                <div class="panel-heading">文章列表</div>
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                    <tr>
                        <th><input type="checkbox"/></th>
                        <th>ID</th>
                        <th>文章标题</th>
                        <th>所属课程</th>
                        <th>发布日期</th>
                        <th>阅读量</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for emp in writ %}
                        <tr>
                            <td><input type="checkbox" class="checks"/></td>
                            <td class="id">{{ emp.course_id }}</td>
                            <td>
                                <a href="{% url 'manage:update' %}?id={{ emp.course_id }}&&level={{ level }}&&cate_id={{ emp.cate_id }}">{{ emp.course_name }}</a>
                            </td>
                            <td>{{ emp.cate.title }}</td>
                            <td>{{ emp.time|date:'Y年m月d日 H：i：s' }}</td>
                            <td>{{ emp.count }}</td>
                            <td>
                                <button class="btn btn-warning dele">删除</button>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
                <div aria-label="Page navigation" class="pull-right pagitor-manager">
                    <ul class="pagination">
                        {% if writ.has_previous %}
                            <a href="{{ url1 }}&&number={{ writ.previous_page_number }}&&ride_time={{ ride_time }}&&ride_count={{ ride_count }}&ride_type=0">上一页</a>
                        {% endif %}


                        {% for n in writ.paginator.page_range %}
                            {% if writ.number == n %}
                                <a class="b"
                                   href="{{ url1 }}&&number={{ n }}&&ride_time={{ ride_time }}&&ride_count={{ ride_count }}&ride_type=0">{{ n }}</a>
                            {% else %}
                                <a class="a"
                                   href="{{ url1 }}&&number={{ n }}&&ride_time={{ ride_time }}&&ride_count={{ ride_count }}&ride_type=0">{{ n }}</a>
                            {% endif %}
                        {% endfor %}

                        {% if writ.has_next %}
                            <a href="{{ url1 }}&&number={{ writ.next_page_number }}&&ride_time={{ ride_time }}&&ride_count={{ ride_count }}&ride_type=0">下一页</a>
                        {% endif %}


                    </ul>
                </div>
            </div>
            <!--分页显示-->
        </div>

    </div>

</div>
<div class="footer">
    <div class="container">
        <div class="row">
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-heart-empty glyphicon"></span> 关注我们</h4>
                        <p>最受欢迎的管理平台</p>
                        <p><a href="#" class="ic_df"> 新浪微博</a></p>
                        <p><a href="#" class="ic_weichat"> 官方微信</a></p>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-king"> 开发平台</span></h4>
                        <p>加入开发平台，尊享会员福利，成为资深程序猿</p>
                        <p class="p_idea"><a href="http://www.baizhibest.com"
                                             class="btn btn-default btn-lg idea">我要开发</a></p>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-phone-alt"></span> 关于我们</h4>
                        <p>欢迎反馈宝贵意见</p>
                        <p class="p_idea"><a href="http://www.baizhibest.com"
                                             class="btn btn-default btn-lg idea">意见反馈</a></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 cp_info">
                <div class="no-mp">
                    <p>CopyRight © 2020 北京百知教育科技有限公司 All Rights Reserved</p>
                    <p>电话：010-****888 京ICP备*******8号</p>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>

<script>
    $(function () {
        $(".sort2").each(function () {
            {
                var ride_time={{ride_time}}
                if (ride_time===1) {
                    $(this).find("#sort2").attr("class", "glyphicon glyphicon-arrow-up")

                } else {
                    $(this).find("#sort2").attr("class", "glyphicon glyphicon-arrow-down")

                }

            }
        })
    })

    $(function () {
        $(".sort1").each(function () {
            {
                var ride_count={{ride_count}}
                console.log('ride_count='+ride_count)
                if (ride_count===1) {
                    $(this).find("#sort1").attr("class", "glyphicon glyphicon-arrow-up")

                } else {
                    $(this).find("#sort1").attr("class", "glyphicon glyphicon-arrow-down")
                }
            }
        })
    })

</script>


</body>
</html>
